home *** CD-ROM | disk | FTP | other *** search
/ PC Users 1998 March / Pc Users extra 6.iso / pshare95 / prog / formula1 / vcform1.z / ReportWriter.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1997-09-17  |  7.5 KB  |  225 lines

  1. VERSION 5.00
  2. Object = "{13E51000-A52B-11D0-86DA-00608CB9FBFB}#5.0#0"; "VCF15.OCX"
  3. Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.1#0"; "COMDLG32.OCX"
  4. Begin VB.Form ReportWriter 
  5.    BackColor       =   &H00C0C0C0&
  6.    Caption         =   "Report Writer"
  7.    ClientHeight    =   7935
  8.    ClientLeft      =   165
  9.    ClientTop       =   510
  10.    ClientWidth     =   11325
  11.    Icon            =   "ReportWriter.frx":0000
  12.    LinkTopic       =   "Form1"
  13.    ScaleHeight     =   7935
  14.    ScaleWidth      =   11325
  15.    StartUpPosition =   2  'CenterScreen
  16.    Begin VB.CommandButton btnViewReport 
  17.       Caption         =   "&View Report"
  18.       Height          =   480
  19.       Left            =   15
  20.       TabIndex        =   2
  21.       Top             =   3900
  22.       Visible         =   0   'False
  23.       Width           =   1815
  24.    End
  25.    Begin VB.ListBox lstFields 
  26.       DragIcon        =   "ReportWriter.frx":000C
  27.       Height          =   3765
  28.       Left            =   15
  29.       TabIndex        =   1
  30.       Top             =   75
  31.       Visible         =   0   'False
  32.       Width           =   2835
  33.    End
  34.    Begin MSComDlg.CommonDialog CommonDialog1 
  35.       Left            =   10770
  36.       Top             =   330
  37.       _ExtentX        =   847
  38.       _ExtentY        =   847
  39.       _Version        =   327680
  40.    End
  41.    Begin VCF150Ctl.F1Book F1Book1 
  42.       Height          =   7830
  43.       Left            =   15
  44.       TabIndex        =   0
  45.       Top             =   60
  46.       Width           =   11295
  47.       _ExtentX        =   19923
  48.       _ExtentY        =   13811
  49.       _0              =   $"ReportWriter.frx":0156
  50.       _1              =   $"ReportWriter.frx":055B
  51.       _2              =   $"ReportWriter.frx":0960
  52.       _3              =   $"ReportWriter.frx":0D65
  53.       _4              =   $"ReportWriter.frx":116A
  54.       _count          =   5
  55.       _ver            =   1
  56.    End
  57.    Begin VB.Line Line2 
  58.       BorderColor     =   &H80000005&
  59.       X1              =   -45
  60.       X2              =   11280
  61.       Y1              =   15
  62.       Y2              =   15
  63.    End
  64.    Begin VB.Line Line1 
  65.       BorderColor     =   &H80000003&
  66.       X1              =   -60
  67.       X2              =   11280
  68.       Y1              =   0
  69.       Y2              =   0
  70.    End
  71.    Begin VB.Menu mnuFile 
  72.       Caption         =   "&File"
  73.       Begin VB.Menu mnuFileNewReport 
  74.          Caption         =   "&New Report"
  75.       End
  76.       Begin VB.Menu mnuFileOpen 
  77.          Caption         =   "&Open"
  78.          Begin VB.Menu mnuFileOpenDatabase 
  79.             Caption         =   "&Database"
  80.          End
  81.          Begin VB.Menu mnuFileOpenReport 
  82.             Caption         =   "&Report"
  83.          End
  84.       End
  85.       Begin VB.Menu mnuFilePrint 
  86.          Caption         =   "&Print"
  87.       End
  88.       Begin VB.Menu mnuFilePrintPreview 
  89.          Caption         =   "Print Pre&view"
  90.       End
  91.    End
  92.    Begin VB.Menu mnuFormat 
  93.       Caption         =   "&Format"
  94.       Begin VB.Menu mnuFormatCells 
  95.          Caption         =   "&Cells..."
  96.       End
  97.       Begin VB.Menu mnuFormatResizeColumns 
  98.          Caption         =   "&Resize Columns"
  99.       End
  100.    End
  101. Attribute VB_Name = "ReportWriter"
  102. Attribute VB_GlobalNameSpace = False
  103. Attribute VB_Creatable = False
  104. Attribute VB_PredeclaredId = True
  105. Attribute VB_Exposed = False
  106. Private Sub btnViewReport_Click()
  107.     Dim RecordCount As Long
  108.     Dim ColumnCoun As Long
  109.     Dim RecSet As Recordset
  110.     Dim nRow As Long
  111.     Dim x As Integer
  112.     Dim y As Integer
  113.     Dim i As Integer
  114.     Dim j As Integer
  115.     Dim SQLFields As String
  116.     nRow = 0
  117.     With ReportWriter.F1Book1
  118.         .ShowRowHeading = False
  119.         .ShowColHeading = False
  120.         .ShowGridLines = False
  121.         .ShowSelections = F1Off
  122.         .PrintGridLines = False
  123.             
  124.     End With
  125.         
  126.     For x = 1 To SQL.Fields.Count
  127.         SQLFields = SQLFields & SQL.Fields.Item(x).Name & ", "
  128.     Next x
  129.     SQLFields = Left(SQLFields, Len(SQLFields) - 2)
  130.     Set RecSet = dbs.OpenRecordset("Select " & SQLFields & " From " & SelectFields.cboTables.Text)
  131.     RecSet.MoveLast
  132.     RecSet.MoveFirst
  133.     nRow = 0
  134.     RecordCount = RecSet.RecordCount
  135.     ColumnCount = RecSet.Fields.Count
  136.     F1Book1.TextRC(RecordCount, ColumnCount) = "Test"
  137.     F1Book1.TextRC(3, ColumnCount) = "Test"
  138.     F1Book1.SetSelection 3, ColumnCount, RecordCount, ColumnCount
  139.     F1Book1.EditCopyDown
  140.     ReDim FieldPos(2, ColumnCount) As Long
  141.     For x = 1 To ColumnCount
  142.         For i = 1 To 256
  143.             For j = 1 To 20
  144.                 If F1Book1.TextRC(j, i) = "{" & SQL.Fields(x).Name & "}" Then
  145.                     FieldPos(1, x) = j
  146.                     FieldPos(2, x) = i
  147.                 End If
  148.             Next j
  149.         Next i
  150.     Next x
  151.     For x = 1 To RecordCount
  152.         For y = 0 To ColumnCount - 1
  153.             If nRow >= ReportWriter.F1Book1.MaxRow Then
  154.                 Exit For
  155.             End If
  156. '            ReportWriter.F1Book1.TextRC(nRow, 1) = RecSet.Fields(y).Name
  157.             If Not IsNull(RecSet.Fields(RecSet.Fields(y).Name).Value) Then
  158.                 ReportWriter.F1Book1.TextRC(FieldPos(1, y + 1) + nRow, FieldPos(2, y + 1)) = RTrim(RecSet.Fields(RecSet.Fields(y).Name).Value)
  159.             End If
  160.         Next y
  161.         If nRow < ReportWriter.F1Book1.MaxRow Then
  162.             nRow = nRow + 1
  163.             ReportWriter.F1Book1.AddRowPageBreak nRow
  164.         End If
  165.         RecSet.MoveNext
  166.     Next x
  167.     ReportWriter.F1Book1.SetColWidthAuto -1, -1, -1, -1, False
  168.     ReportWriter.F1Book1.SetRowHeightAuto -1, -1, -1, -1, False
  169.     F1Book1.Left = F1Book1.Left - 2880
  170.     F1Book1.Width = F1Book1.Width + 2880
  171.     lstFields.Visible = False
  172.     btnViewReport.Visible = False
  173. End Sub
  174. Private Sub F1Book1_DragDrop(Source As Control, x As Single, y As Single)
  175.     Dim nRow As Long
  176.     Dim nCol As Long
  177.     F1Book1.TwipsToRC x, y, nRow, nCol
  178.     F1Book1.TextRC(nRow, nCol) = "{" & Source.Text & "}"
  179.     F1Book1.SetColWidthAuto -1, nCol, -1, nCol, False
  180.     SQL.Fields.Add Source.Text, Source.Text
  181. End Sub
  182. Private Sub Form_Load()
  183.     Set SQL = New SQLInfo
  184. End Sub
  185. Private Sub lstFields_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)
  186.     If Button = 1 Then
  187.         lstFields.Drag 1
  188.     End If
  189. End Sub
  190. Private Sub mnuFileNewReport_Click()
  191.     F1Book1.InitTable
  192.     Unload NewReport
  193.     Unload SelectFields
  194.     Unload Grouping
  195.     Unload Sorting
  196.     NewReport.Show 1
  197. End Sub
  198. Private Sub mnuFileOpenDatabase_Click()
  199.     CommonDialog1.Filter = "*.mdb"
  200.     CommonDialog1.ShowOpen
  201.     ' Create Microsoft Jet Workspace object.
  202.     Set wrkJet = CreateWorkspace("", "admin", "", dbUseJet)
  203.     ' Open Database object from saved Microsoft Jet database.
  204.     Set dbs = wrkJet.OpenDatabase(CommonDialog1.filename, False)
  205.     ReportWriter.Caption = "Report Writer -- " & CommonDialog1.filename
  206. End Sub
  207. Private Sub mnuFilePrint_Click()
  208.     F1Book1.FilePrintEx True, True
  209. End Sub
  210. Private Sub mnuFilePrintPreview_Click()
  211.     F1Book1.FilePrintPreview
  212. End Sub
  213. Private Sub mnuFormatCells_Click()
  214.     F1Book1.FormatCellsDlg F1AllPages
  215. End Sub
  216. Private Sub mnuFormatResizeColumns_Click()
  217.     If F1Book1.ShowSelections = F1On Then
  218.         F1Book1.ShowSelections = F1Off
  219.     Else
  220.         F1Book1.ShowSelections = F1On
  221.     End If
  222.     F1Book1.ShowColHeading = Not F1Book1.ShowColHeading
  223.     F1Book1.SetFocus
  224. End Sub
  225.